# Definition for singly-linked list.

class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next

def CreateLisNode(l:list[int]) -> ListNode:
    L = ListNode(l[0].val)
    lc = L
    for i in l[1:]:
        lc.next = ListNode[i]
        lc = lc.next
    return L


class Solution:
    def deleteDuplicates(self, head: Optional[ListNode]) -> Optional[ListNode]:
        if head == None:
            return head
        L = ListNode(head.val)
        l1 = head
        l2 = L
        while l1 != None:
            if l1.val != l2.val:
                l2.next = ListNode(l1.val)
                l2 = l2.next
            l1 = l1.next
        return L

if __name__ == '__main__':
    s = Solution()
    print(s.deleteDuplicates(CreateLisNode([1,1,2])))